fixed OOM bug when generating picture thumbnails