fix image autoscaling to behave reasonably with empty scales, and to avoid NaNs.