how to convert stream to byte array in c