Fix compilation with OpenCL on MacOS X

Also fix crash in the case of OpenCL error during encoding.