open files in binary mode when necessary