Workaround for cffi issue 140

Proposed fix for #762. Uses most of the same code that cffi uses for creating its internal modulename, although we don't have to if people would prefer something simpler.