added binary write support