Plistlib and json modules have conflicting requirements for their dump
methods: Plistlib expects its file handle to be a writable binary file
object while json expects it to be a writable text file object.
This commit solves this issue by dumping the JSON into a temporary
string which is encoded to UTF-8 (JSON format RFC 7159 requires UTF-8,
UTF-16 or UTF-32 encoding and UTF-8 is the recommended default) before
being output. This allows to keep delegating file opening to Click and
avoid a refactoring to abstract the opening mode between supported
formats.