Always correct encoding when writing to sys.stderr (Fixes #1435)