Fix the bug preventing the pickle writting

The file to dump the pickle needs to be opened as binary. Now it is
fixed.