Planning with Diffusion for Flexible Behavior Synthesis