Fix encoding error when printing to redirected output

When redirecting output to a file sys.stdout.encoding is None, so use
sys.getdefaultencoding() instead.
Fix encoding error when updating with redirected output

When output is redirected sys.stdout.encoding is None. Fix this by
always encoding to utf-8, assuming gitlab handles that. The encoding
used by the local system is irrelevant here.