support file-like object passed to read method