I figured it out! I used a different tactic. When he changed to berserk form, I went into the in game debug menu and put the number 92 on his skills. This makes him keep 1 hp if he is defeated. So when I selected to battle him, I immediately made him switch to my team using the control enemies code. And when I defeated him, he still had one hp left due to the code I put on him. Then I used a warp to another level code and I got him on my team!