Support reading from and writing to file-like objects.