jpeg unpacking with optimization