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
Merge pull request #4247 from ivan/info-json

Fix #4246 and #4244 .info.json bugs