Kshedden mixed rebased of #1398

rebased and python 3 compat changes of PR #1398 mixed effects models