Gold prices end lower, but tally a second straight monthly gain