Fix jpeg link

This pull request replaces "-ljpeg" with cmake find_package and ${JPEG_LIBRARY}.

Tested on Mac 10.9, Ubuntu 12.04 and 14.04.