Is it permissible to purchase the bricks and timber belonging to a mosque?

It is permissible if the shar‘i-legal trustee decides to sell them, and it is permissible to change them for the better.