Fix DDS image writing

The code did not correctly do the 90-degree rotation needed for DDS,
and would fail on non-square images.

Task-number: QTBUG-39899
Change-Id: I1599e3fe44ff7895db8aa6e325fa8fdba2106694
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>