set prototype.constructor when overwriting prototype

this is a fix for issue #550

it's my first commit, i hope everything is correct