Added 'write_image' function. Worked, but too slow