Open output files in binary mode in the testsuite

This fixes running tests on windows.
Include <algorithm> for std::min

This fixes building the test code on MSVC 2013.

(Actually building all of the tests on windows still is tricky
due to the OpenSSL dependency for SHA1, but there's a patchset
in review to take care of that.)
Merge pull request #265 from mstorsjo/fix-tests-windows

Fix building/running tests on windows