Use fopen instead of glib fopen as it can cause problem when glib fopen doesn't use the same descriptor as the one of the system.
Merge remote-tracking branch 'origin/fix_osx' into dev