this should do the trick.
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPWeb Web = properties.Feature.Parent as SPWeb;
Web.MasterUrl = Web.Site.RootWeb.ServerRelativeUrl + "/_catalogs/masterpage/CustomMaster.master";
Web.CustomMasterUrl = Web.Site.RootWeb.ServerRelativeUrl + "/_catalogs/masterpage/CustomMaster.master";
Web.Update();
foreach (SPWeb subweb in Web.GetSubwebsForCurrentUser())
{
subweb.MasterUrl = Web.MasterUrl;
subweb.CustomMasterUrl = Web.CustomMasterUrl;
subweb.Update();
subweb.Dispose();
}
Web.Dispose();
}