Added explicit text-encoding to file read/write operations
This patch adds various encoding='utf-8'
arguments to file read+write operations to improve robustness and to address recommendations from Python-3.10 that assuming a default encoding is fragile. (See also pep-0597.)