i/o function for image processing