Updated as_variable_name to Python 3

All tests in glue/core/tests/test_utils.py pass in Python 2, three fail in Python 3 because of code in different modules.