Fix loading of inline JPEG images

This is a tentative patch to fix loading of inline JPEG images, based on this paragraph: http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#page=223&zoom=auto,0,600.

Fixes #2812.
Fixes #4776.
Fixes [bug 1065245](https://bugzilla.mozilla.org/show_bug.cgi?id=1065245)

Also fixes missing images in (but the text is still incorrect):
#2840.
#4054.
would you consider implementing a peekByte() in Stream?

    peekByte: function Stream_peekByte() {
      var byte = this.getByte();
      this.pos--;
      return byte;
    },

i think thats cleaner