the problem is in this line
$fp = fopen( "signature_IMG/\\\$acc2.canvas.png", 'wb');
u hv given 3 backward slash (\). these are used to escape character.
if u want to escape for one backward slash then give \\ or if u want two \\ then give \\\\
then it will solve ur problem. here in ur code the 3rd \ is escaping the $ symbol and treating "acc2" as normal character.