use TextIOWrapper when communicating with pandoc subprocess

uses 'universal-newline' mode, to avoid any confusion with CRLF.

closes #4122 
closes #3819

alternative to #4202