Added a size argument to generateThumbnail