Apply quality option only to JPEG images

The quality option is specific to JPEG and should not be applied to other formats. For instance, it could lead to wrong PNG compression level.

Also fixed a possible error (imagepng() arguments shifted) in GD with PNG if filter specified but not quality.

----------------------------------------
follow-up to #259