This patch deduplicates quite a bit of stuff in image.c, otherwise the
additional complexity from tiles would have been a lot more.
The only thing that's not working yet is packed UDIMs in Cycles with OSL.
As far as I can tell everything works, but to be honest, I'm not very
familiar with how packed images are supposed to behave so some more
testing would probably be a good idea.