The endgame turns difficult because of your passive bishop (almost all of your pawns are on the same color as the bishop) but I'm not sure if it's so easy for white to break through if you don't let his king into d5. After 38... Kd7? 39. Kd5 black is lost I think but you could try something else (say 38... Bd2).
Earlier, however, you could even hope for an advantage thanks to you active king.
I lost this game in the endgame and reaalized that a knight is much better in a crowded endgame than a bishop. Any middle game, strategic, e,game ideas,etc. Would be much appreciated