Cardiff cinema secures funding to avoid permanent closure