It's something, not sure about "correct". That will add the remainder of width divided by 16 (between 0 and 15) to the width, which now that I think about it more isn't quite what you want. Give this a whirl:
width += 16 - (width % 16);
height += 16 - (height % 16);
That should be the right math. There's still some question as to exactly where to add it in the code, and if any other code needs to be adjusted, but give that a try in the same place.