Fix compilation with OpenCL on MacOS X

Also fix crash in the case of OpenCL error during encoding.
Merge branch 'plain' into 7mod