[OSX] Remove all direct calls to CFStringGetCString and CFStringGetCStringPtr

This adds a new util function DarwinCFStringToString that handles errors
and tries to first get the pointer otherwise copies the string into a
std::string. It also makes sure to use CFStringGetSystemEncoding()
everywhere so we don't get in trouble for using a hardcoded encoding.