Do createImageData/putImageData in chunks, to save memory.

As previously seen at https://bugzilla.mozilla.org/show_bug.cgi?id=959925.