Vastly simplify reading of images
Add a utility function for writing out files