fix jpeg parsing, rework parser to defer buffer management

The idea here is to let the buffer be a sliding window of sorts, and to
have it only contain the current marker segment at any given time.

I left the PNG parser alone, so it still works the old way (the buffer
contains everything up to the IHDR segment). GIF keeps the size in a
well known location, so there was never any memory issue there.

JPEG was the tricky one, so that was the focus. I added two real-world
JPEGs that were breaking the parser.