Allow compilation on Linux and OSX

This pull request allows clean compilation on both Linux and OSX. The problem was in the way fmemopen was detected, which is now more sane. Tested on OSX Mavericks and on Ubuntu 12.04 LTS.