More Exception Handling

Added more exception handling for imagejpeg() and imagegif().
Added the ability to set the desired quality for imagejpeg() for full,
small, and thumbnail images.