Switch to binary stdout when necessary. Closes #350. Closes #346.