Re-add support to in memory Opencv io

I've tried to recover @kloudkl commit. @shelhamer I know that we have a warning: "CV_XADD" redefined but we could limit this to osx and remove when the next opencv release will be out.