Fixed some bugs that occurred in Python 3.5 but were not present in Python 2.7. Most compatiblity issues were caused by incompatible type casting of numpy arrays.