Jesus was God in the form of man, and God in heaven is in a completely different form. when Jesus says God alone is good, it is because man, in his corruption, is not good, and God being in the form of a man at that time could not have claimed that that was good.
Matthew 26:41
Watch and pray, that ye enter not into temptation: the spirit indeed is willing, but the flesh is weak.
John 4:24
God is a Spirit: and they that worship him must worship him in spirit and in truth.