Move the loop that sets the pixels in DirectUtils::createImage from Java to a JS native

Fixes #315.
Doesn't the image also need to be made mutable?