Fix issue 857

Fixed issue #857. When saving a JPEG and specifying 'keep' for quality or subsampling, if the source JPEG image is in grayscale mode, don't try to find the subsampling of the source, because grayscale images don't have any subsampling (it's only for color components).

For the moment the fix also ignores subsampling of CMYK JPEG because currently Pillow doesn't support encoding JPEG in YCCK mode (and subsampling doesn't make sense in CMYK, but Pillow permits saving CMYK JPEG with subsampling, that's a bug). This fix pass those errors silently, i.e. it doesn't raise an error when 'keep' is used but it's not possible to keep the subsampling (because the image is grayscale or CMYK). I think it's the proper behavior but I'm not sure.

I added tests.