Add function to create memory from stream