Pass mode parameter on windows

Closes #134
fix mem leak in example

Closes #133
Fix wrong fwrite arguments order in example

Closes #132
working