Fixes problem with Google App Engine

Adds IndexError to the except statement, making it work for Google App Engine. Related to #279