BUG: Cannot save categorical index to HDF5
- [X] I have checked that this issue has not already been reported.

- [X] I have confirmed this bug exists on the latest version of pandas.

- [ ] (optional) I have confirmed this bug exists on the master branch of pandas.

---

#### Code Sample

```python
import pandas as pd
cat = pd.Categorical(['A', 'B'])
df = pd.DataFrame([[1, 2], [3, 4]], index=cat)
df.to_hdf("test.h5", "/test")
```

#### Problem description

Attempting to save a dataframe with a categorical index fails with an AssertionError:
```python-traceback
Traceback (most recent call last):
  File "pandas_bug.py", line 4, in <module>
    df.to_hdf("test.h5", "/test")
  File "/usr/lib/python3.8/site-packages/pandas/core/generic.py", line 2490, in to_hdf
    pytables.to_hdf(
  File "/usr/lib/python3.8/site-packages/pandas/io/pytables.py", line 282, in to_hdf
    f(store)
  File "/usr/lib/python3.8/site-packages/pandas/io/pytables.py", line 265, in <lambda>
    f = lambda store: store.put(
  File "/usr/lib/python3.8/site-packages/pandas/io/pytables.py", line 1030, in put
    self._write_to_group(
  File "/usr/lib/python3.8/site-packages/pandas/io/pytables.py", line 1697, in _write_to_group
    s.write(
  File "/usr/lib/python3.8/site-packages/pandas/io/pytables.py", line 3094, in write
    self.write_index(f"axis{i}", ax)
  File "/usr/lib/python3.8/site-packages/pandas/io/pytables.py", line 2770, in write_index
    converted = _convert_index("index", index, self.encoding, self.errors)
  File "/usr/lib/python3.8/site-packages/pandas/io/pytables.py", line 4732, in _convert_index
    assert isinstance(converted, np.ndarray) and converted.dtype == object
AssertionError
```
It is expected that this would work and it has worked in previous Pandas versions.

#### Expected Output

A HDF5 file containing the dataframe.

#### Output of ``pd.show_versions()``

The following system produces the bug:

<details>

```
INSTALLED VERSIONS
------------------
commit           : None
python           : 3.8.2.final.0
python-bits      : 64
OS               : Linux
OS-release       : 5.6.8-arch1-1
machine          : x86_64
processor        : 
byteorder        : little
LC_ALL           : None
LANG             : en_AU.utf8
LOCALE           : en_AU.UTF-8

pandas           : 1.0.3
numpy            : 1.18.3
pytz             : 2019.3
dateutil         : 2.8.1
pip              : 20.0.2
setuptools       : 46.1.3
Cython           : 0.29.17
pytest           : None
hypothesis       : None
sphinx           : None
blosc            : 1.9.0
feather          : None
xlsxwriter       : 1.2.8
lxml.etree       : 4.5.0
html5lib         : 1.0.1
pymysql          : None
psycopg2         : None
jinja2           : 2.11.2
IPython          : 7.13.0
pandas_datareader: None
bs4              : 4.9.0
bottleneck       : None
fastparquet      : None
gcsfs            : None
lxml.etree       : 4.5.0
matplotlib       : 3.2.1
numexpr          : 2.7.1
odfpy            : None
openpyxl         : 3.0.3
pandas_gbq       : None
pyarrow          : None
pytables         : None
pytest           : None
pyxlsb           : None
s3fs             : None
scipy            : 1.4.1
sqlalchemy       : 1.3.16
tables           : 3.6.1
tabulate         : 0.8.7
xarray           : None
xlrd             : None
xlwt             : None
xlsxwriter       : 1.2.8
numba            : 0.49.0
```

</details>

The following system works as expected (downgrade to Pandas 0.25.3):

<details>

```
INSTALLED VERSIONS
------------------
commit           : None
python           : 3.8.2.final.0
python-bits      : 64
OS               : Linux
OS-release       : 5.6.8-arch1-1
machine          : x86_64
processor        : 
byteorder        : little
LC_ALL           : None
LANG             : en_AU.utf8
LOCALE           : en_AU.UTF-8

pandas           : 0.25.3
numpy            : 1.18.3
pytz             : 2019.3
dateutil         : 2.8.1
pip              : 20.0.2
setuptools       : 46.1.3
Cython           : 0.29.17
pytest           : None
hypothesis       : None
sphinx           : None
blosc            : 1.9.0
feather          : None
xlsxwriter       : 1.2.8
lxml.etree       : 4.5.0
html5lib         : 1.0.1
pymysql          : None
psycopg2         : None
jinja2           : 2.11.2
IPython          : 7.13.0
pandas_datareader: None
bs4              : 4.9.0
bottleneck       : None
fastparquet      : None
gcsfs            : None
lxml.etree       : 4.5.0
matplotlib       : 3.2.1
numexpr          : 2.7.1
odfpy            : None
openpyxl         : 3.0.3
pandas_gbq       : None
pyarrow          : None
pytables         : None
s3fs             : None
scipy            : 1.4.1
sqlalchemy       : 1.3.16
tables           : 3.6.1
xarray           : None
xlrd             : None
xlwt             : None
xlsxwriter       : 1.2.8
```

</details>
