fixed bugs in thumbnail generation of downsampled images