Correct packing for square texture (previous code would increase the
size of the image after packing. the new one packs to square image
directly, giving better result).