Structural changes of a bacteriophage upon DNA packaging and maturation