Added a bit of error checking to Image library