JPEG/JFIF image decoder from scratch