use a stream, this way it also works for public shared galleries and with encryption enabled
Merge pull request #1507 from owncloud/fix_thumbnail_generation

use a stream to generate previews