Fix arrow keys and tab completion, broken after stdout utf8 fix.

Before d4578e1, the following happened when stdout was not connected to
an interactive terminal:

~/src/git/m2ee-tools/src (develop) 2-$ ./m2ee.py about | cat
INFO: The application process is running, the MxRuntime has status: running
INFO: Logged in users: (0) []
INFO: Application Name: M2EE Test
Traceback (most recent call last):
Using m2ee-tools version UNRELEASED
Using Mendix Runtime version 5.1.1
  File "./m2ee.py", line 1004, in <module>
    cli.onecmd(' '.join(args))
  File "/usr/lib/python2.7/cmd.py", line 221, in onecmd
    return func(arg)
  File "./m2ee.py", line 378, in do_about
    print(feedback['copyright'])
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa9' in position 10: ordinal not in range(128)

The reason is, that when the output is not a terminal, the encoding of
sys.stdout is not set. i.e. print sys.stdout.encoding returns None.

The fix in d4578e1, replacing stdout with a writer that is forced to
utf8, breaks using the arrow keys and tab completion in Cmd, at least on
my workstation (Debian Jessie). I still have no idea why.

~/src/git/m2ee-tools/src (develop) 2-$ ./m2ee.py
INFO: The application process is running, the MxRuntime has status: running
INFO: Logged in users: (0) []
INFO: Application Name: M2EE Test
m2ee(knorrie): ^[[A^[[C^[[D^[[B^[[D^[[C^[[B^[[A

So, improve the fix by only using this stdout hack when stdout is not
attached to a terminal.

Also, use locale.getpreferredencoding() instead of hard forcing 'utf8':

~/src/git/m2ee-tools/src (develop) 2-$ python
Python 2.7.6 (default, Feb 26 2014, 00:34:35)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> print locale.getpreferredencoding()
UTF-8

So long for another edition of programming using digital duct tape and
WD40. :-|