Make it compile in MacOSX

I added support for Mac OSx (e.g. Lion, Mavericks and possibly Yosemite)