Allow rendering image data to memory

Changes the file rendering to allow both saving to file and writing to memory.