Added in code to copy back the image buffer.