[compat] correct OptionGroup invocation for Python 3 (fixes #4243)
Fix UnicodeEncodeError with --write-info-json on Python 2.7 + Windows

Fixes #4244
Fix "ERROR: Cannot write metadata to JSON file" on Windows

Fixes #4246