Improve parsing to avoid redundant copying and stack allocation, which can avoid errors with files that have really large embedded images.
Merge pull request #256 from dgileadi/optimize-parser

Improve parsing to avoid redundant copying and stack allocation