Merge pull request #11910 from brendon/master

Use binary mode to write uploaded files [ci skip]