Writing to image mostly working