See my comments on the previous commit about this. The 'maxBytes' attribute should be maxPixels, and the var bytes below has got to be var pixels.  I don't think that any of this code has anything to do with bytes.