Sorry I got no idea - your method sounds okay to me.
I usually do things the other way though - isolate the image over a transparent background first, then add a new layer (ctrl-shift-N), then fill with uniform colour (Shift-F5), then drag it below the foreground layer, then save for web.
All I can suggest is keep an eye on the borders at every single step of the way and see where it's introduced. Especially if you crop the final image down at the end.