jpgjs performance improvements

importing https://github.com/notmasteryet/jpgjs/pull/22