All perfect praise be to Allah, The Lord of the Worlds, and may His peace and blessings be upon our Prophet Muhammad and upon all of his family and companions.
Taking a salary for being an Imam is permissible since some of the companions took money against performing Ruquia and when they asked the Prophet (PBUH), he said (What means):" How do you know that Surat-al-Fatiha is a Ruqya? Take it (flock of sheep) and assign a share for me." [Al-Bukhary]. It is stated in [Nihayat Al-Muhtaj 1/417], a Shafie book, :" It is permitted for a Mu'zan (A man who calls Muslims to prayer from a Mosque) to perform his job voluntarily (For free). However, if he wanted a salary for that, the guardian is allowed to give him that; yet he is not permitted to assign one (Mu'zan) if there was a volunteer for this job.
In addition, any of the subjects is permitted to give him a salary for doing the aforementioned job."
In conclusion, both, the Mu'zan and the Imam are permitted to take a salary from one of the subjects since it is not conditioned that it should be taken only from the guardian.
Moreover, the case mentioned in the above question is considered Ji`alah (A payment in return for the performance of a job), and it is worth mentioning here that a Muslim shouldn't be eager to collect money in return for working as an Imam since Allah, The Exalted, will reward him for that in the Hereafter. And Allah knows best.