Use io:format("~ts", ...) instead of stdout

`io:format` with `"~ts"` seems to handle unicode iolist
correctly, so use it instead of port_command.

Code is tested on erlang 17.0. It seems that unicode support for erlang is
introduced recently, so I'm not sure if `"~ts"` breaks compatibility with older
erlang releases.