Change code to write to file instead of just keeping image in memory.  This is to preserve the filename when sharing image.