Make sure use of unicode when using IO_read/write_stringref is explicit.
Added check for nil string when using IO_read_stringref_utf8.