More error checking around converting a string into a buffer object.