Fixed resizing and cropping

Now thumbnails can be just about any size or aspect ratio and it should
work. Refactored a bit by moving resize and crop code into their own
methods.