c++ jpeg decoder written from scratch