A study of the reactions π+d → dπ+π−π+ and π+d → dπ+π−π+π0 at 11.7 GeV/c