COD: write function to read images
COD: write/test function to write out images