Fix #949.
Use binary mode to write file if unix_newlines is set.
Merge remote-tracking branch 'johnmave126/fix-unix_newlines-on-windows'