Fixed invalid character handling in UTF-8 encoder

Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>