Miscellaneous bug and pyodbc compatibility fixes

Here are some fixes and changes I needed to make to drop pypyodbc into a project which currently uses pyodbc. I think being compatible out-of-the-box is a good thing to aim for(?). I haven't run any of the test suites, I'm afraid, but it seems to work in my project!