Implemented write_image()