Allow specifying maximum height / width

Closes #5
Fix for Python 3
Merge pull request #9 from matt-thomson/issue5

Allow specifying maximum height / width