get code to work with OpenCV3
actually fixes #46 properly