Fix #6509: Interactive container hangs when redirecting stdout

These two commits fix both:
- `docker run --rm -i ubuntu cat /etc/passwd | grep root` should not hang (issue #6509)
- `docker events > /tmp/out` should not print control characters to non-terminal STDOUT (commit 26b4a4920adca614f6be17a96f254f331271faf0)