Separated the image-packing code into a separate library for possible reuse.