Well if you own the company it is going to be complicated with your local tax office but well possible. I think you need to consult a lawyer to help you.
I have already the answer, it was in the tax treaty between my country and the country of incorporation. It was stated that if the person who receive the royalties is also involved in the company then, it is considered distributed profits and the tax is the same than dividends.
Could you set up new company that owns all the IP, it could then lease back to original company. Good tax adviser would definitely know if that is possible
That is possible. Actually that's one of the major reasons why many IT companies actually register their companies offshore for instant in Romania, Cyprus, Malta etc.