Fixed issues with jpeg decoding