Use IO.pipe in binary mode (fixes encoding issues)