Time-dependent analysis of B0 -->’ KS0pi+pi-gamma decays and studies of the K+pi-pi+ system in B+ --> K+pi-pi+gamma decays