The current code only works when you are creating a subsite of one level deep. If you want to create a subsite of two levels deep, make sure you add the root in the (Custom)MasterUrl. Otherwise it will give an 404 error, because it can't find default.aspx. the MasterPage of default.aspx to be precise. So as an extention the previous correction:
CustomMasterUrl="/_catalogs/masterpage/mydefault.master"
MasterUrl="/_catalogs/masterpage/mydefault.master"