use TextIOWrapper when communicating with pandoc subprocess

uses 'universal-newline' mode, to avoid any confusion with CRLF.

closes #4122

alternative to #4202