add Pathname.write_binary

Part of #26424 but can go in sooner.