added binary flags in i/o functions