Have you try to compile dlib or opencv without jpeg support?
Then you can try :
[> OpenCV image objects can be converted into a form usable by dlib routines by using cv_image. You can also convert from a dlib matrix or image to an OpenCV Mat using dlib::toMat().](dlib C++ Library - Frequently Asked Questions)