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>
Merge remote-tracking branch 'origin/5.3' into dev

Change-Id: I15c1f7d4fd700c04f3f27720fc79abd3827eeeed