Replace invalid characters with U+FFFD (fixes #96)