Pass pointer between python and C++

try

CV_EXPORTS_W bool imencode( const String& ext, InputArray img,
CV_OUT std::vector& buf,
const std::vector& params = std::vector(),
InputArray workspace);