added some function for write/read bytestream