Make building work with Mingw

Applied changes by @imbaczek
Merge pull request #170 from bvssvni/master

Make building work with Mingw