Write image in openFrameworks

hello all
how can save an image in openframework
to opencv with imwrite command:
imwrite(cv:mat,filename);
save mat file
for example i want save bellow mat in raspberry pi(raspbian jessei)

cv::Mat frame,resizeF,fgMaskMOG2,output;

frame = cam.grab();
if(!frame.empty())
{
//imwrite(frame,“test1.jpg”);
??
}

Do you need to use openCV in particular? ofImage has the ability to save images already built in:
http://openframeworks.cc/documentation/graphics/ofImage/#!show_save