ansi2thml.sh: fix trailing space at end of lines

Also relegate sed to simple matching and replacement,
leaving awk to handle backspacing and <span> handling etc.
Screens are now reproduced more accurately and quickly.
Also there is improved support for cursor movement within lines.