maybe 8. Bb2 and 9.Qd2 would have been better to castle queenside. but it's just a supposition^^
Game Analysis
4. g3 looked questionable to me. Playing e3 would kind of imply that you're using the a5-f1 diagonal for your light-squared bishop. Deciding to fianchetto the bishop lets your opponent take the diagonal, as he did on the next move. I personally would have played 4. c4.
7. b3 makes some queenside weaknesses without getting that bishop off the diagonal.
8. a4 isn't good, letting his other bishop take the b4 square. Especially with his other bishop already trapping your king, letting him play Bb4 like that only hampers the position more.
13. b4 lost a pawn. I would have just castled first.
23. d4 blocked in the bishop and didn't do much else.
25. Rfc1 kinda blocks in the other rook. I would have probably gone with Rac1 so that both rooks have a little freedom. (In other words, it should have gone 25. Rac1 Ra8 26. Rfe1. The way you played it loses a tempo.)
27. d5 is the kind of move that you needed to focus a little more on. You already know why this was a bad move, so I suggest you just think a little more next time you think you've won material.
33. Rac1 loses a pawn (I think). Even if I'm wrong, that wasn't the time to go on the offensive. His last move shouts that he's going offensive, so you should have been a little more defensive here. His knight is really strong, and it will take accurate defense to avoid being mowed down.
40. Kh2?? - You've got to watch for this kind of setup. Even if that didn't lose any material, you handed him an easy attack.
I just played this game against an opponent that was stronger than I was and I personally thought I was doing pretty well. At one point I was leading in material and I thought I was going to win, but then I made some mistakes and he made some smart moves and I lost.
I would appreciate it if you would leave any feedback about what else I did wrong and what I could've done. Also, perhaps you could let me know what I need to work on?
Thanks in advance!