Removed unused variable
Fixed bad JS assignment
Fixed saving JPEGs with Imagick destroyed resource
Improved style