modified the serialize()/fromFile functions to serialize to binary