Simple rectangle packing code, useful for creating textures for OpenGL