fix interlaced thumbnails

we need to cache the thumbnail before we write it in case the writer
needs to make several passes

see https://github.com/jcupitt/libvips/issues/140