Add untested support for setting data of a region of an image.
Cleanup.