python: Fix unsafe utf-8 decodings