Add full fit to viewport support.

So far the fit to viewport only scaled the image if it was wider than the viewport and not if it was higher.
This fix will scale the image if it is either wider, higher, or both than the viewport, based on which scaling factor is larger (see this Stackoverflow question: http://stackoverflow.com/a/1106367/368102).