WINGS: A WIde-field Nearby Galaxy-cluster Survey - II. Deep optical photometry of 77 nearby clusters