You need to recompile OpenCV and add support for the "jpeg" format. Get the latest opencv code and run cmake:
svn co http://code.opencv.org/svn/opencv/trunk/opencv myopencvdir.svn/ cd myopencvdir.svn/ mkdir release cd release/ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
And check if libjpeg, libpng, libtiff are supported. If not, you need to install them and restart cmake.
Example cmake output that shows Media I / O support:
-- Media I/O: -- ZLib: TRUE -- JPEG: TRUE -- PNG: TRUE -- TIFF: TRUE -- JPEG 2000: TRUE -- OpenEXR: YES
source share