Thumbnail bug fix

Ensures there is no mix up in thumbnail images by using NamedTemporaryFile.