Adds flushing of stdout and stderr after writes

Because output is written without ever closing the fds until sys.exit is
called after a `KeyboardInterrupt` exception, it is difficult to read
stdin or stdout from a parent process that may spawn a development
server subprocess.

https://code.djangoproject.com/ticket/19593