read file from buffer