Force UTF8 output if stdout of command line compiler is redirected

The typical way of using "twee" is to redirect its output to an HTML
file. However, such a redirect will use ASCII encoding unless
overriden by the PYTHONIOENCODING environment variable. Therefore it
would break if the output contains Unicode characters.

To avoid that, check whether we are outputting to a tty or to a file
and in the latter case, explictly encode as UTF8 (with BOM).
Optimized the concatenation of Twee story fragments

The main thing is to avoid adding to a string repeatedly, since this
requires an increasing number of bytes to be copied again and again
as the string grows. Instead, pass a generator to join().
Commit 3914ac50 does something similar for HTML fragments.

Added "order" argument to docstring.

Changed the "not order" check to "order is None": if the user passes
an empty sequence for "order", the correct output is the empty string.
Add "untwee" command line tool

This is similar to the old Twee "untwee" tool: it reads a story
in HTML format and outputs in Twee format.

The code is derived from the "twee" script though rather than from
the original "untwee" script.