handle jpeg compression with different image spectrums

also, define a custom jpeg compression error handler which will
pass the error to the baton.