Fixes offset overflow in retile

The offset computation here can overflow since x,y,z, tile*begin, tw, th are all ints. So computation happens in ints and that is then cast to size_t.
That causes maketx to crash for textures bigger than 32k x 32k. I have verified that in 0.1, and 1.1
Could this be backported to the older branches too?
Thanks!
r