although this PR is not supposed to deal with Python 3 errors, the file() usage introduces more failing tests than really needed: https://travis-ci.org/scrapy/scrapy/jobs/22199989#L1587

Fix should be as simple as `s/file(/open(/` but also use 'wb' as open mode.