Python 3 fix for thumbnail generation.