Open output file in binary mode in download()

This fixes #553.