A factory reset is easy. All you need for this is in the attachment (except the latest stock ROM, which is much too large for an upload here). It's available on SamMobile for your country, you only have to register, it's for free. Now first charge your battery to 100%.
Hint: The Pit files must be unzipped!
1. Install on your Windows PC the Samsung drivers. These are important that your PC will recognize the phone.
2. Unzip Odin to any folder on your PC (ex: Odin)
3. Put your S2 into the download mode (press the buttons home, power and volume down at the same time).
4. Connect your phone to your PC via USB cable and start Odin as an administrator (important!).
5. Load the one-part stock ROM in Odin into PDA, the stock 2GB Pit file into PIT. Now hit the start button and the flash goes on.
6. Wait until the blue bar on the phone screen has gone through and the green display PASS! appears in Odin. It takes a few minutes, be patient. CAUTION: Don't disconnect or turn off your phone, until the flash is finished. Otherwise you risk a brick!
7. Welcome back to stock ROM! If you don't want to flash a custom ROM, you can stop reading here.
So now we want to flash the custom ROM. This needs more space, the phone must to be repartitioned.
1. Go through steps 1-6 above, but load the Pit file 1GB_6GB into Odin instead of stock 2GB Pit.
2. After the stock ROM is running, turn your phone off and put it into download mode.
3. Start Odin and load the TWRP recovery in PDA, press the start button. Wait until recovery is started.
4. In recovery, go to Wipe/Extended Wipe. Choose from: Cache, Dalvik Cache, System, Data and wipe it all.
5. Copy the custom ROM (perhaps a SU to have root access) and Google Apps (GApps) from your PC to the internal SD card (eMMC).
6. Go to Install in recovery, select the ROM and then the GApps, perhaps it is a separate SU needed to install to have root access later. Is everything installed, wipe the cache/dalvik cache and reboot the system. It takes several minutes, best drink a cup of coffee.
7. Welcome to the custom ROM setup!