Tightly pack the texture with multilevel sort

- Also round width and height to a multiple of 4 pixels to
  ensure 32-bit alignment when using 8-bit/pixel formats
  and to optimize OpenGL texture compression