Fix to make a file read binary if such mode was set.
Add cast to string on binary mode check.
Change binary read fix to be compatible with ruby 1.8.7.