Added the capability to save images and exit from within a file