[fix] Special case ESC

This escapes '\x1b' to '\u001b' in JSON as a special case, since '\x1b'
is used in coloring output.

Change the way we allocate memory for escaping JSON - actually count
characters we'll use instead of blindly shooting for maximum number of
characters.

Fixes #33.