For JPX decoding only read next packet after checking for byte aligning.

This patch makes the image from #5349 appear correctly, however artefacts
for the last packet seem to still be there.
This patch also optimizes some "in-checks" and adds a few header parsings.
ah well I removed this initially but then it breaks the #3591 pdf.
so it has to stay, even when its not really clear to me why.