ENH: Expanduser in to_file methods GH9066

closes #9066
 
First time contributor, tried to follow all rules as good as possible.
If something is missing please let me know.

As specified in task 9066 tilde in a pathname get resolved into a absolute path.
In case the object is a buffer the buffer will be returned.

I did not add additional tests, since I could not find any module explicitly testing pandas/io/common.py
if that is necessary please let me know how to do that. The current tests are passing on my system and seem to cover the method below.

Best Regards,
Ah... I know we have some bad examples in the existing codebase, but please don't add new blanket `except` clauses. (Under `_is_s3_url`, it really should be `except ImportError`.)

If expanduser does not raise a sane exception, you could use `isinstance(filepath_or_buffer, pandas.compat.string_types)`