Implement _sage_ helpers for re/im functions

fixes #4230
Merge pull request #8222 from skirpichev/4230-fix

Implement _sage_ helpers for re/im functions