Fix encoding issues with a PTY