Fix the bug of writting binary file