bindings: Return errors in Result rather than setting an out parameter

Fixes #909.