remove unused previewFiles variable
remove unused previewFilesTmp variable
improve error-checking in generation of preview .png