Make fmemopen work on OSX.
Fix jpeg loading from a path.