Implements onerror for JpegStreams

Partly addresses #2812. It resolves the infinite loop and renders everything but the images.

Thanks to @yurydelendik for helping with debugging this!
Done. This makes the console messages much nicer.