Fix non-power-of-2 sub-image alignment

When adding an image from a file with multiple sub-images, there was an
alignment error if the sub-image width was not a power of 2.