safe_str is no longer relevant after unicode strings are no longer explicit string types.
Popen takes bytes by default now, not strings, which is fixed by setting an encoding
sys.stdout.write should work with strings on linux at least. We only use it for the buy menu timeout, which already only works on linux, so it shouldn't be a problem.