As Paul Vargas states in his answer, there is no conflict with either account if the gifts were received after the presentation in the Temple.
Another detail in Matthew seemingly at odds with Luke is the place at which the gifts were received:
And she gave birth to her firstborn son and wrapped him in swaddling cloths and laid him in a manger, because there was no place for them in the inn. (Luke 2:7 ESV)
And going into the house, they saw the child with Mary his mother, and they fell down and worshiped him. Then, opening their treasures, they offered him gifts, gold and frankincense and myrrh. (Matthew 2:11 ESV)
The differences can easily be reconciled. Since they were poor at the time of presentation and not staying in a house, the gifts were received after the birth and presentation, as Paul Vargas shows. Placing the Magi with the couple at the time of birth is a Christmas tradition not supported by Scripture.
After the presentation the family returned to Nazareth. We are told that within a year of the birth they traveled back to the area of the birth to observe the Passover:
Now his parents went to Jerusalem every year at the Feast of the Passover. (Luke 2:41 ESV)
Travelers to Jerusalem at the time of Passover would need to find lodging. Joseph's family lived in Bethlehem, about 5 miles south of Jerusalem. Luke's birth account also states shepherds, Simeon, and Anna were witnesses to the fact the Christ had been born. In particular Luke states:
And when they saw it, they made known the saying that had been told them concerning this child. And all who heard it wondered at what the shepherds told them. (Luke 2:17-18 ESV)
Whatever stigma Mary's pregnancy initially brought within Joseph's family would be tempered by this testimony. So the next year when the family traveled to Jerusalem to observe the Passover, they were welcomed to stay with family. And it was at this time the Magi came and presented their gifts.
Once the truth of the annual observance of the Passover is accepted, all of the conflicts are resolved. Luke is describing birth events and Matthew is describing events which occurred at the time of Passover. The only uncertainty is whether it was the Passover in the first or second year of birth. If the star appeared at the time of birth it could be the second year; if the star appeared at the time of conception it would be the first year.
My preference is to place Jesus' exodus to Egypt at the time of His first Passover.