Pictures sizing issue

The default picture settings in CS cart for the product images are 320 x 320 pixels. This was causing some of my images to be stretched either vertically or horizontally to fit. I removed the 320 height requirement, so the images are 320 pixels wide now, but some of them get stretched to fit so they end up being 800+ pixels tall.

Is there a way I can have the picture max width or height be 320 pixels without distorting the image? Thanks.