Improve error reporting of JPEG image encoder

OpenCV issue #2604

After this patch applied an attempt to encode empty images produces exception
saying "Raw image encoder error: Empty JPEG image (DNL not supported)"
Merge pull request #344 from taka-no-me:improve_jpeg_encoder_errors