Support for max texture size on some GPUs

Scale the image and its parameters to avoid going over the max 2D texture
size supported on WebGL on a particular browser. Tested on Chrome.