Changed all the fopen mode strings from "r" to "rb" where binary files were openend. This seems to be a requirement in windows (with no effect in Linux presumably).