Polish

Created constant maxval for largest possible dimension
Scaling only if image larger than maxval
Scale based on largest dimension now, not just width