Fixed bug with integer overflow on the scale when using large images (>=...

...4096 on a side).