Improve io.ascii.read guess when inputting file objects

In Python 3 (only) the following fails:
```
from astropy.io import ascii
t = ascii.read(open('astropy/io/ascii/tests/t/ipac.dat.bz2', 'rb'))
```
This is closely related to #3013 and issues raised in #3109.  This PR puts in a fix in the `ui._guess()` which reads the entire file into memory if a file object is supplied.  This fixes the Python 3 problem and should be more efficient in Python 2 because the file is not re-read during the guess process.