Streamlined the writeout of images