jpgjs performance improvements

see https://github.com/notmasteryet/jpgjs/pull/22
Fix for the offByOne-error and small performance optimisations
Merge pull request #4497 from yurydelendik/jpgjs22

jpgjs performance improvements