More robust image resizing (Issue 2207)
Merge pull request #456 from hssm/image-resize-fix

More robust image resizing (Issue 2207)