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. On my 2011 Macbook pro, this was necessary.