Jesus was saying, 'Don't call me good, because only God is good', therefore he was effectively stating that he was not God.
On the contrary the Lord calls Himself God here and is raising the man's idea of Him to divinity. St. Bede and St. Theophylact say it best perhaps:
Bede: "But by this one God, Who is good, we must not only understand the Father, but also the Son, who says, 'I am the good Shepherd;' (John 10:11) and also the Holy Ghost, because it is said, 'The Father which is in heaven will give the good Spirit to them that ask him.' (Luke 11:13) For the One and Undivided Trinity itself, Father, Son, and Holy Ghost, is the Only and One good God. The Lord, therefore, does not deny Himself to be good, but implies that He is God; He does not deny that He is good Master, but He declares that no master is good but God."
Theophylact: "Therefore the Lord intended by these words to raise the mind of the young man, so that he might know Him to be God. But He also implies another thing by these words, that when you have to converse with a man, you should not flatter him in your conversation, but look back upon God, the root and fount of goodness, and do honor to Him."