Implement _sage_ helpers for re/im functions

fixes #4230