Fix potential "expected a character buffer object" errors