build: always use utf-8 when reading/writing text files
open() in text mode should never be used without an encoding because it defaults to the locale encoding which is rarely what is wanted.
This fixes the Windows build in some cases (depending on the locale/paths used)