fix mac support and rewrite write_object_data.cpp
Merge pull request #588 from qwook/master

fix mac support and rewrite write_object_data.cpp